package com.itheima.FileTest;

import java.io.*;
import java.util.Arrays;
import java.util.TreeSet;

public class Test {
    public static void main(String[] args) throws IOException {
        File f = new File("Module2\\number1.txt");
        TreeSet<Integer> ts = new TreeSet<>();
        if (f.isFile()) {
            BufferedReader br = new BufferedReader(new FileReader(f));
            String line;
            while ((line = br.readLine()) != null) {
                int number = Integer.parseInt(line);
                ts.add(number);
                System.out.println(ts);
            }
            br.close();

            BufferedWriter bw = new BufferedWriter(new FileWriter("Module2\\number2.txt"));
            for (Integer t : ts) {
                bw.write(t + "");
                bw.newLine();
                bw.flush();
            }
            bw.close();


        }


    }
}

